package com.jmxcfc.blfsc.common.validation;


import java.util.regex.Pattern;

/**
 * 正则表达式规则校验器
 */
public class RegexRuleValidator implements IRuleValidator<String> {

    private String regular;

    private RegexRuleValidator(String regular) {
        this.regular = regular;
    }

    public static RegexRuleValidator of(String regular) {
        return new RegexRuleValidator(regular);
    }

    @Override
    public boolean isValid(String value) {
        return Pattern.matches(this.regular, value);
    }
}
